<?php
//include Header
$path = $_SERVER['DOCUMENT_ROOT'];
include("$path/header.php");
if(isset($_SESSION['sessionid'])){
	$result = mysql_query("select * from bestellingen,bestelstatus where bestellingen.klantnummer = " . $_SESSION['klantnummer'] . " and bestellingen.bestellingsnummer = " . $_REQUEST['bn'] . " and bestellingen.statusnummer = bestelstatus.statusnummer;",$server);
	$num_rows = mysql_num_rows($result);
	if($num_rows > 0){
	echo "
		<center>
			<h1>
				Bestelling " . $row['bestellingsnummer'] . "
			</h1>
			<table border=\"1\" id=\"bestellingsinfo\" width=\"30%\">
				<thead>
					<tr>
					</tr>
				</thead>
				<tfoot>
					<tr>
					</tr>
				<tfoot>
				<tbody>";
		while($row = mysql_fetch_array($result)){
			echo"
					<tr>
						<td>
							Bestelnummer:
						</td>
						<td>
							" . $row['bestellingsnummer'] . "
						</td>
					</tr>
					<tr>
						<td>
							Besteldatum:
						</td>
						<td>
							" . $row['besteldatum'] . "
						</td>
					</tr>
						<td>
							afleverdatum:
						</td>
						<td>
							" . $row['afleverdatum'] . "
						</td>
					</tr>
					<tr>
						<td>
							Status:
						</td>
						<td>
							" . $row['statusnaam'] . "
						</td>
					</tr>
				";
		}
		echo"
				</tbody>
			</table>
			<h1>
				Producten
			</h1>
			<table border=\"1\" id=\"productTable\" width=\"70%\">
				<thead>
					<tr>
					</tr>
				</thead>
				<tfoot>
					<tr>
					</tr>
				<tfoot>
				<tbody>";
		$result = mysql_query("select * from producten,bestelregel where producten.productnummer = bestelregel.productnummer and bestelregel.bestellingsnummer = " . $_REQUEST['bn'] . "",$server);
		$totaalprijs = 0;
		while($row = mysql_fetch_array($result)){
		  echo "
					<tr>
						<td>
							<a href=\"product.php?id=" . $row['productnummer'] . "\"><img src=\"/images/producten/thumb_" . $row[image] . "\" /></a>
						</td>
						<td>
							<a href=\"product.php?id=" . $row['productnummer'] . "\">" . $row['productnaam'] . "</a>
						</td>
						<td>
							&euro;" .sprintf("%01.2f", ($row[prijs]/100)) . "
						</td>
						<th>
							" . $row['aantal'] . "
						</th>
						<td width=\"150\">
							&euro;" .sprintf("%01.2f", ($row['aantal'] * $row['prijs']) / 100) . "
						</td>
					</tr>
				";
			$totaalprijs += ($row['aantal'] * $row['prijs']);
		}
		echo"
					<tr>
						<td>
						</td>
						<td>
						</td>
						<td>
						</td>
						<td>
						</td>
						<td>
							<font color=red><h3>&euro;" .sprintf("%01.2f", $totaalprijs / 100) . "</h3>
						</td>
					</tr>
				</tbody>
			</table>
		</center>";
	}
} else {
	echo "<h1>Niet ingelogd</h1>";
}

//include footer
include("$path/footer.php");
//nieuwe text!!!
?>